package org.chenzhi.allinpaymvp.mvp.presenter;

import android.widget.Toast;

import org.chenzhi.allinpaymvp.mvp.biz.AgeBiz;
import org.chenzhi.allinpaymvp.mvp.view.SimpleView;
import org.chenzhi.mvp.base.BasePresenter;

/**
 * @author orange
 */

public class SimplePresenter extends BasePresenter<SimpleView> {
    private AgeBiz ageBiz;

    public SimplePresenter() {
        ageBiz = new AgeBiz();
    }

    public void calc() {
        String year = getView().getYear();
        int age = ageBiz.calc(year);

        Toast.makeText(getContext().getApplicationContext(), "我要开始计算了",
                Toast.LENGTH_SHORT).show();

        switch (age) {
            case AgeBiz.AGE_TOO_LARGE:
                getView().showMsg("您的年龄已经突破天际了！");
                break;
            case AgeBiz.NOT_VALID_BIRTH:
                getView().showMsg("这个似乎不是地球的年份呢，检查是否输入错误了(ー`´ー)");
                break;
            case AgeBiz.HAVE_NOT_BORN:
                getView().showMsg("您还没有出生呢！");
                break;
            case AgeBiz.AGE_MAY_TOO_LARGE:
                getView().showMsg("您是一个长寿的老人！");
                break;
            default:
                getView().showMsg("您已经" + age + "岁！");
                break;
        }
    }
}
